Skip to content

Feature fit all - #604

Draft
PILIPALA030 wants to merge 7 commits into
Snapmaker:mainfrom
PILIPALA030:feature_fit_all
Draft

Feature fit all#604
PILIPALA030 wants to merge 7 commits into
Snapmaker:mainfrom
PILIPALA030:feature_fit_all

Conversation

@PILIPALA030

Copy link
Copy Markdown
Collaborator

Description

Screenshots/Recordings/Graphs

Tests

- Add ZoomToFit() to GLCanvas3D that prioritizes selection,
  then volumes, then bed depending on context
- Render a Fit Camera icon button next to the 3D navigator
  in the viewport via ImGui (light/dark/hover variants)
- Bind 'Z' key as global shortcut for fit camera, with
  guard against text entry focus, running gizmos, and
  ImGui keyboard capture
- Add Fit Camera entry to the View menu
- Add 4 fit_camera SVG icons and register them in
  GLGizmosManager icon textures
- Fix init_icon_textures() to skip reloading if already
  initialized
- Document 'Z' shortcut in KBShortcutsDialog
- Add zh_CN translations for the new UI strings
Add Model::InitializeAssemblyPositions() to place newly imported objects
sequentially along the X-axis with 10mm spacing, matching BambuStudio's
assembly view behavior. Multiple instances of the same object stack along
the Y-axis. All objects are auto-grounded on Z-axis.

Apply assembly position initialization to all object creation paths:
- Handy model insertion (GUI_Factories)
- Internal mesh loading (GUI_ObjectList)
- File import for raw geometry formats: STL/OBJ/GLB/GLTF/FBX (Plater)
- Copy/paste (Selection)
- Text emboss job (EmbossJob)
- Fill bed job (FillBedJob)

3MF project files are intentionally excluded as they preserve their own
position data.
Consolidate three duplicate i18n strings ("Fit camera to scene or
selected object.", "Fit Camera", "Camera view - Fit to scene or
selection") into a single "Fit in all view" label, used consistently
across tooltip, shortcut dialog, and menu item.
- perf: batch InitializeAssemblyPositions in FillBedJob::finalize
  (was per-item in the setter -> O(N^2) full-scene traversal)
- fix: iterate loaded objects forward so assembly-view order matches
  load order (was reversed via rbegin/rend) at all three call sites
- refactor: drop _L() on the Fit Camera ImGui window ID (hidden by
  NoTitleBar, polluted the translation catalog); use a plain
  std::string ID, also resolving begin() overload ambiguity
Comment thread src/libslic3r/Model.cpp Outdated
Comment thread src/libslic3r/Model.cpp Outdated
Comment thread src/libslic3r/Model.cpp Outdated
Comment thread src/libslic3r/Model.cpp Outdated
A single invalid object (empty mesh, null/duplicate instance, etc.)
previously made InitializeAssemblyPositions return false and leave the
whole batch uninitialized. Rework it to skip invalid items and continue
with the valid ones.

- Return void instead of bool; no caller used the result.
- Skip null/undefined-mesh objects and null/undefined-box instances
  instead of aborting the batch.
- Pre-size instanceBoxes and keep them index-aligned with instances;
  skipped slots stay defined==false and are filtered consistently.
- Use a firstValidInstance flag instead of instanceIndex == 0 so Y
  stacking is correct when instances[0] is null or degenerate.
- Bind rawBox to raw_mesh_bounding_box()'s cached const reference.
Registering the bare "Z" as a menu keyEquivalent on macOS would route
the shortcut through the menu's wxCommandEvent, which only checks
can_change_view() and bypasses the stricter ShouldSkipFitCameraShortcut
guard (text-entry focus / ImGui wants keyboard / gizmo running) used in
the wxEVT_CHAR_HOOK handler. On macOS the shortcut is therefore left to
the CharHook path only, and the menu label omits the "\tZ" accelerator.
Windows/Linux keep showing it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants